<template>
  <div>
  <home-header></home-header>
  <home-swiper :swiperList="swiper"></home-swiper>
  <home-icons :iconList="icon"></home-icons>
  <home-other :otherList="other" :yLike="otherLike"></home-other>
  <home-week :weekLits="week"></home-week>
  </div>
</template>

<script>
  //使用header组件
  import HomeHeader from '../components/Header.vue'
  import HomeSwiper from '../components/Swiper.vue'
  import HomeIcons from '../components/Icon.vue'
  import HomeOther from '../components/Other.vue'
  import HomeWeek from  '../components/Week.vue'
  //引入axios
  import axios from 'axios'

  export default {
    name: "Home",
    components:{
        HomeHeader,
        HomeSwiper,
        HomeIcons,
        HomeOther,
        HomeWeek
    },
    data(){
      return{
          swiper:[], //swiper 数据
          icon:[],
          other:[],
          otherLike:[],
          week:[]
      }
    },
    methods:{
        getHomeInfo(){
            axios.get('static/index.json').then(this.getSucc)
        },
      getSucc(res){
            res=res.data
        if(res.ret && res.data){
                const data =res.data
                this.swiper=data.Imgsrc //请求swiper数据
                this.icon=data.iconList
                this.other=data.otherList
                this.otherLike=data.yLikeList
                this.week=data.WeekList
        }
            console.log(res)
      }
    },
    mounted(){ // (钩子函数)  主要用来向后台请求拿到数据后做一些业务处理,
        this.getHomeInfo();
    }
  }
</script>

<style scoped>

</style>
